home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-26 | 3.1 KB | 81 lines | [TEXT/GEOL] |
- Item 9763868 6-June-89 22:46
-
- From: CREMER.M Cremer, Mike
-
- To: UK0034 Baum, Peter, Uk Dev London
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: Re: TStdPrintHandler query
-
- Peter,
-
- For each and every printable view, the view should also have a printhandler
- object. For views that do not print, no printhandler should be created.
-
- Given: (a) all separate view are in separate windows; (b) you are taking
- default page setup options for margins, etc.
-
- Consider: Suppose I have two views, TPrintMeView and TDontPrintMeView, both of
- which I display on the screen. When I create each view, my method will look
- something like:
-
- { Create a TPrintMeView }
-
- IF (forPrinting)
- THEN { we're printing directly, so no need for a window object }
- printMeView := TPrintMeView(DoCreateViews(SELF, NIL, kPrintMeView))
- ELSE { we're creating a screen view, so make the window }
- BEGIN
- aWindow := NewTemplateWindow(kPrintMeWindow, SELF);
- printMeView := TPrintMeView(aWindow.FindSubView('VW01'));
- END;
-
- { next step is used only when creating a printable view }
-
- New(aPrintHandler); FailNIL(aPrintHandler);
- aPrintHandler.IStdPrintHandler(SELF, { its document }
- printMeView, { its view }
- FALSE, { does not have square dots
- TRUE, { horzontal page size is fixed
- TRUE); { vertical page size is fi
-
- { Create a TDontPrintMeView }
-
- IF (forPrinting)
- THEN { nothing, since we can't print a TDontPrintMeView }
- ELSE
- BEGIN
- anotherWindow := NewTemplateWindow(kDontPrintMeWindow, SELF);
- dontPrintMeView := TPrintMeView(anotherWindow.FindSUbView('VW02'));
- dontPrinMeView.fPrintHandler := NIL;
- END;
-
- { end of codeFrag }
-
- Note that this is normally done in a TDocument.DoMakeViews. If you are
- creating these views in TApplication, then the SELF parameters should be NIL.
-
- From here on out, let MacApp worry about which menus to enable or disable.
- MacApp will check to see if a print handler is installed and let the print
- handler enable the menu items it can handle (the default TView.DoSetupmenus
- calls fPrintHandler.DoSetupMenus). If you haven't installed a print handler,
- the Print… etc. menus will not be enabled.
-
- As far as printing the correct view when Print… is selected, MacApp uses the
- target view's printhandler (if it exists), to handle the command.
- Specifically, TView.DoMenuCommand will trap Print… commands and direct them to
- its printhandler (if installed). What is probably happening is that the
- non-printable views are passing the Print… commands on to the next EvtHandler
- because they have no printhandler to process the menu command, and the next
- Evthandler in the chain happens to be a printable view. The simplest solution
- is to override TView.DoMenuCommand in the non-printable views, trap all the
- Print… commands, and do nothing with them (look in TView.DoMenuCommand to see
- what I mean).
-
- Hope this helps.
-
- $mike cremer
- Apple Computer, Inc.
-
-